import { createUniqueString } from '@/utils'

const files = require.context('./', true, /\.vue$/)

const components = {}

const modules = [
  {
    id: 'header',
    title: '页面头部',
    options: {
      bgImg: {
        top: '',
        bottom: ''
      },
      search: {
        show: true,
        placeholder: ''
      },
      swiper: {
        show: true,
        showStyle: '12px 20px 0px',
        imgStyle: '100% 100%'
      },
      hints: [
        {
          icon: '',
          text: '免费配送'
        },
        {
          icon: '',
          text: '晚到必赔'
        },
        {
          icon: '',
          text: '专业检测'
        },
        {
          icon: '',
          text: '30分钟达'
        }
      ]
    },
    selectable: false
  },
  {
    id: 'navigation',
    title: '图文导航',
    style: {
      backgroundPosition: '-10px -345px',
      hoverBackgroundPosition: '-50px -345px'
    },
    limit: 1,
    options: {
      banner: {
        showStyle: '12px 12px 0px',
        imgStyle: '100% 100%'
      },
      showStyle: '12px 12px 0px',
      bgColor: '',
      fontColor: '',
      iconStyle: '50%'
    },
    selectable: true
  },
  {
    id: 'announcement',
    title: '通知公告',
    style: {
      backgroundPosition: '-90px -345px',
      hoverBackgroundPosition: '-130px -345px'
    },
    limit: 1,
    options: { },
    selectable: true
  },
  {
    id: 'special',
    title: '今日特价',
    style: {
      backgroundPosition: '-250px -345px',
      hoverBackgroundPosition: '-290px -345px'
    },
    limit: 1,
    options: {
      banner: {
        show: true,
        imgUrl: '',
        showStyle: '12px 12px 0px',
        imgStyle: '100% 100%'
      },
      scroll: false
    },
    selectable: true
  },
  {
    id: 'recommend',
    title: '热卖推荐',
    style: {
      backgroundPosition: '-10px -384px',
      hoverBackgroundPosition: '-50px -384px'
    },
    limit: 1,
    options: {
      banner: {
        show: true,
        imgUrl: '',
        showStyle: '12px 12px 0px',
        imgStyle: '100% 100%'
      },
      scroll: false
    },
    selectable: true
  },
  {
    id: 'seckill',
    title: '秒杀',
    style: {
      backgroundPosition: '-330px -345px',
      hoverBackgroundPosition: '-370px -345px'
    },
    limit: 1,
    options: {
      title: '',
      count: 3
    },
    selectable: true
  },
  {
    id: 'footer',
    title: '底部导航',
    options: {
      navItems: [
        {
          text: '首页',
          sortable: false,
          removable: false,
          _uid: createUniqueString()
        },
        {
          text: '分类',
          sortable: false,
          removable: false,
          _uid: createUniqueString()
        },
        {
          text: '购物车',
          sortable: false,
          removable: false,
          _uid: createUniqueString()
        },
        {
          text: '我的',
          sortable: true,
          removable: false,
          _uid: createUniqueString()
        }
      ],
      fontColor: {
        default: '',
        active: ''
      },
      bgColor: ''
    },
    selectable: false
  }
]

modules.forEach(({ id }) => {
  const view = files(`./${id}/view.vue`).default
  const options = files(`./${id}/options.vue`).default
  components[id + 'View'] = view
  components[id + 'Options'] = options
})

export { components, modules }
